/* Copyright © 2007 sample Computer Corporation Limited
 * All rights reserved.
 * 
 * Date: 2007-6-15
 * author: fungus  (fungus@gmail.com)
 *
 */
package com.glodon.ggzy.core.model;

import java.util.List;


/**
 * 
 * 
 * 分页处理类
 * @author zhangxj
 * @since jdk1.6
 * @date 2013-6-17
 *
 */
public class Page extends BaseModel {

	private int currentPage;

	private int pageSize = 20;

	private long pageCount;

	private long totalCount;

	private List<?> result;

	public Page() {

	}

	public Page(int curretPage, int pageSize) {
		this.currentPage = curretPage;
		this.pageSize = pageSize;
	}

	public Page(int currentPage, int pageSize, int totalCount) {
		this.currentPage = currentPage;
		this.pageSize = pageSize;
		this.totalCount = totalCount;
	}

	public Page(List<?> result) {
		this.result = result;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public long getPageCount() {
		return pageCount;
	}

	public void setPageCount(long pageCount) {
		this.pageCount = pageCount;
	}

	public int getPageSize() {
		return pageSize;
	}

	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	public List<?> getResult() {
		return result;
	}

	public void setResult(List<?> result) {
		this.result = result;
	}

	public long getTotalCount() {
		return totalCount;
	}

	public void setTotalCount(long totalCount) {
		this.totalCount = totalCount;
	}

	public static long getPageCount(long totalCount, int pageSize) {
		if (totalCount < 0 || pageSize <= 0)
			return 0;
		if (totalCount % pageSize == 0)
			return totalCount / pageSize;
		else
			return totalCount / pageSize + 1;
	}

	@Override
	public String toString() {
		return "page [currentPage=" + currentPage + ", pageCount=" + pageCount + ", pageSize=" + pageSize + ", result.size()=" + result.size()
				+ ", totalCount=" + totalCount + "]";
	}
}
